package edu.aysf.service.impl;

import edu.aysf.dao.GoodsDao;
import edu.aysf.entity.GoodsEntity;
import edu.aysf.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsDao GoodsDao;

    // 新增商品
    @Override
    public int createGoods(int id,String goods_name,int goods_count,float goods_price,float goods_money) {
        return GoodsDao.createGoods(id,goods_name, goods_count , goods_price, goods_money );
    }
    @Override
    public int deleteGoods(int id){
        return GoodsDao.deleteGoods(id);
    }
    // 更新商品库存
    @Override
    public int updateGoods(int goods_id, int goods_count , float goods_price ,float goods_money) {
        return GoodsDao.updateGoods(goods_id,goods_count,goods_price,goods_money);
    }

    // 查询所有商品
    @Override
    public List<GoodsEntity> selectGoods() {
        return GoodsDao.selectGoods();
    }

    // 根据Id查询商品
    @Override
    public List<GoodsEntity> selectGoodsById(int id) {
        return GoodsDao.selectGoodsById(id);
    }

    @Override
    public List<GoodsEntity> selectGoodsByName(String goods_name) {
        return GoodsDao.selectGoodsByName(goods_name);
    }

    // 查询商品单价
    @Override
    public Float selectGoodsPrice(int goods_id) {
        return GoodsDao.selectGoodsPrice(goods_id);
    }

    // 查询商品库存数量
    @Override
    public int selectCount(int goods_id) {
        return GoodsDao.selectCount(goods_id);
    }

}
